package HeSuanServer.controller;

import HeSuanServer.POJO.R.Result;
import HeSuanServer.POJO.User;
import HeSuanServer.POJO.UserSearch;
import HeSuanServer.service.UserCliService;
import HeSuanServer.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @描述:
 * @author: LH
 * @date: 2023/4/7
 */
@CrossOrigin
@RequestMapping("user")
@RestController
@Slf4j
public class userController {
    @Autowired
    private UserService userService;
    @Autowired
    private UserCliService userCliService;
    @PostMapping("findByPage")
    public Result findByPage(@RequestBody UserSearch userSearch){
        return userService.findByPage(userSearch);
    }
    @PostMapping("add")
    public Result useradd(@RequestBody User user){
        return userCliService.register(user);
    }
    @GetMapping("byId")
    public Result byId(Integer id){
        return userService.byId(id);
    }
    @PostMapping("edit")
    public Result edit(@RequestBody User user){
        return userService.edit(user);
    }
    @GetMapping("del")
    public Result del(Integer id){
        return userService.del(id);
    }
}
